package com.lcz.mytest.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * 股票历史数据数据库
 * Created by Administrator on 2016/3/30.
 */
public class StockDataHelper extends SQLiteOpenHelper {
    public StockDataHelper(Context context, String name, SQLiteDatabase.CursorFactory factory,
                           int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        // 创建股票历史数据_日数据表
        String sql = "create table stock_daydata(_id Integer primary key,"
                + "code String," + "date String," + "open double,"
                + "high double," + "low double,"
                + "close double," + "average double)";
        db.execSQL(sql);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // 版本更新时调用
        String sql = "drop table stock_daydata";
        db.execSQL(sql);
        onCreate(db);
    }
}
